#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	int l,  m;
	cin >> l >> m;
	int arr[l+1];
	for(int i = 0; i < l+1; i++)
	{
		arr[i] =1;
	}

	
	int left, right;
	while(m--)
	{
		cin >> left >> right;
		for(int i = left; i <= right; i++)
		{
			arr[i] = 0;
		}
	}
	int cnt = 0;
	for(int i = 0; i <= l; i++)
	{
		if(arr[i]==1)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}
